package com.yanqu.road.server.cmd.banquet.goodbanquet;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.banquet.CrossBanquetProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.banquet.baifubanquet.CrossGoodBanquetMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

/**
 * @Description
 * @Author cwq
 * @Data 2021/11/9 17:09
 */
@Cmd(code = Protocol.C2_GOOD_BANQUET_JOIN, desc = "请求百福宴赴宴")
public class CrossGoodBanquetJoinCmd extends CrossCommand {

    long userId;
    int activityId;
    long banquetId;
    private UserBaseInfo userBaseInfo;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossBanquetProto.GoodBanquetJoinReqMsgToCrossReqMsg reqMsg = CrossBanquetProto.GoodBanquetJoinReqMsgToCrossReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        activityId = reqMsg.getActivityId();
        banquetId = reqMsg.getBanquetId();
        userBaseInfo = PlayerBasePb.parseToUserBaseInfo(reqMsg.getPlayerBaseData());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        MessageHelper.sendPacket(serverId, userId, YanQuMessageUtils.buildMessage(GameProtocol.S_GOOD_BANQUET_JOIN_FROM_CROSS, CrossGoodBanquetMgr.joinGoodBanquet(activityId,userId,banquetId,userBaseInfo)));
    }

    @Override
    public void sendData() {

    }
}
